package cn.itsource.org.mapper;

import cn.itsource.org.domain.Employee;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * spring生成代理mapper实现
 * 
 * mybatis第一天学的
 * 
 * UserMapper userMapper = sqlSession.getMapper(UserMapper.class)
 * sout userMapper.getClass   proxy$14534
 *
 * Mapper映射器
 */
public interface EmployeeMapper extends Mapper<Employee> {
    //基础的curd方法由继承得到
    //ctrl+g
    List<Employee> findManagers();

    /**
     * 根据用户名或者邮箱或者手机号查询用户
     */
    @Select("select * from t_employee where username = #{username} or email = #{email} or phone = #{phone}")
    List<Employee> findByUsernameOrEmailOrPhone(Employee admin);

    /**
     * 登录不管是邮件还是手机号还是用户名 ,全都是用username传递的
     * @param employee
     * @return
     */
    @Select("select * from t_employee where username = #{username} or email = #{username} or phone = #{username}")
    Employee findByUsername(Employee employee);

    @Select("select * from t_employee where shop_id = #{shopId}")
    List<Employee> findShopEmps(@Param("shopId") Long shopId);
}
